package com.tegistuff.webos.run.debugger.breakpoints;

import com.intellij.xdebugger.breakpoints.XBreakpointProperties;
import com.intellij.xdebugger.breakpoints.XLineBreakpoint;

/**
 * WebOSBreakpointWrapper.java
 *
 * Wraps all information about a breakpoint that is necessary for further processing.
 *
 * Copyright (C) 2011-2012 Timo Tegtmeier.
 * All rights reserved.
 */
public class WebOSBreakpointWrapper {
    
    private String myFileName;
    private int myLineNumber;
    private int myBreakpointNumber;
    private boolean myEnabled;
    private XLineBreakpoint<XBreakpointProperties> myBreakpoint;

    public WebOSBreakpointWrapper(String fileName, int lineNumber, int breakPointNumber,
                                  XLineBreakpoint<XBreakpointProperties> breakpoint) {
        this(fileName, lineNumber, breakPointNumber, true, breakpoint);
    }

    public WebOSBreakpointWrapper(String fileName, int lineNumber, int breakpointNumber, boolean enabled,
                                  XLineBreakpoint<XBreakpointProperties> breakpoint) {
        myFileName = fileName;
        myLineNumber = lineNumber;
        myBreakpointNumber = breakpointNumber;
        myEnabled = enabled;
        myBreakpoint = breakpoint;
    }

    public final String getFileName() {
        return myFileName;
    }
    
    public final int getLineNumber() {
        return myLineNumber;
    }
    
    public final int getBreakpointNumber() {
        return myBreakpointNumber;
    }

    public final void setEnabled(boolean enabled) {
        myEnabled = enabled;
    }

    public final boolean getEnabled() {
        return myEnabled;
    }

    public final XLineBreakpoint<XBreakpointProperties> getBreakpoint() {
        return myBreakpoint;
    }

    @Override
    public int hashCode() {
        return myFileName.hashCode() * myLineNumber;
    }   

    @Override
    public boolean equals(Object o) {
        if(o instanceof WebOSBreakpointWrapper) {
            WebOSBreakpointWrapper other = (WebOSBreakpointWrapper)o;
            return (myFileName.equals(other.myFileName)) &&
                   (myLineNumber == other.myLineNumber);
        }
        return super.equals(o);
    }
}
